package strategy

import (
	"log"
)

// MustNotPassStrategy 实现
type MustNotPassStrategy struct {
	forbiddenNodes []string // 禁止经过的节点ID列表
}

type MustNotPassConfig struct {
	Nodes []string
}

func (s *MustNotPassStrategy) GetType() ConstraintType {
	return MustNotPass
}

func (s *MustNotPassStrategy) Evaluate(current MultiObjectiveScore, link *LinkWithAttrs) MultiObjectiveScore {
	// 不修改评分，仅用于路径筛选
	return current
}

func (s *MustNotPassStrategy) Apply(args ...interface{}) bool {
	if len(args) < 1 {
		return false
	}

	visited, ok1 := args[0].(map[string]bool)

	if !ok1 {
		return false
	}

	for _, node := range s.forbiddenNodes {
		if visited[node] {
			log.Fatalf("路径经过了禁止节点: %s\n", node)
			return false
		}
	}

	return true
}
